package com.songshuai.webapi.jobapi.common.enumerations;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public enum DicToOldDic {
    //subject
    Subject_chinese(1003001, "chinese"),
    Subject_chemistry(1003003, "chemistry"),
    Subject_english(1003004, "english"),
    Subject_math(1003002, "math"),
    Subject_other(1003006, "other"),
    Subject_physics(1003005, "physics"),

    //grade
    Grade_one(1004001, "one"),
    Grade_two(1004002, "two"),
    Grade_three(1004003, "three"),
    Grade_four(1004004, "four"),
    Grade_five(1004005, "five"),
    Grade_six(1004006, "six"),
    Grade_six_two(1004007, "six"),
    Grade_seven(1004007, "seven"),
    Grade_eight(1004008, "eight"),
    Grade_nine(1004009, "nine"),
    Grade_other(1004100, "other"),

    //signup_status
    Signup_status_no(1028002, "no"),
    Signup_status_yes(1028001, "yes"),

    //degree
    Degree_bechelor(133, "bechelor"),
    Degree_doctor(135, "doctor"),
    Degree_junior(131, "junior"),
    Degree_master(134, "master"),

    //teacher_lv
    Teacher_lv_common(235, "common"),
    Teacher_lv_common_one(234, "common_one"),
    Teacher_lv_senior(233, "senior"),
    Teacher_lv_start_one(232, "star_one"),
    Teacher_lv_star_two(231, "star_two"),
    Teacher_lv_star_three(230, "star_three"),

    //job_status
    Job_status_dimission(713, "dimission"),
    Job_status_practice(300, "practice"),
    Job_status_probation(548, "probation"),
    Job_status_regular(306, "regular"),
    //Job_status_vacation(231, "vacation"), 休假

    // edition
    Edition_beishi(1025007, "beishi"),
    Edition_hujiao(1025006, "hujiao"),
    Edition_huke(1025005, "huke"),
    Edition_other(1025008, "other"),
    Edition_renjiao(1025004, "renjiao"),
    Edition_sujiao(1025003, "sujiao"),
    Edition_waijun(1025002, "waijun"),
    Edition_zhejiao(1025001, "zhejiao");


    private int code;
    private String msg;

    DicToOldDic(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static int getCode(String define){
        try {
            return DicToOldDic.valueOf(define).code;
        } catch (IllegalArgumentException e) {
            log.error("undefined error code: {}", define);
            return 0;
        }
    }

    public static String getMsg(String define){
        try {
            return DicToOldDic.valueOf(define).msg;
        } catch (IllegalArgumentException e) {
            log.error("undefined error code: {}", define);
            return "";
        }
    }

    public static String getMsg(Integer code){
        if(code==null||code<=0)
            return "";
        for(DicToOldDic err : DicToOldDic.values()){
            if(err.code==code){
                return err.msg;
            }
        }
        return "";
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }
}
